#ifndef __WEBSOCKET_REQUEST__
#define __WEBSOCKET_REQUEST__

#include <stdint.h>
#include "debug_log.h"
#include <DL_AES.h>
class Websocket_Request 
{
public:
    Websocket_Request() {};
    Websocket_Request(int fd);
    ~Websocket_Request() {};
    int fetch_websocket_info(char *msg);
    void runconfigdata(char* str, int len, int socket);
    void rungamedata(char* str, int len, int socket);
    void print();
    void reset();
    int websockettoh5(char *content, int length,int fd);
private:
    int fetch_fin(char *msg, int &pos);
    int fetch_opcode(char *msg, int &pos);
    int fetch_mask(char *msg, int &pos);
    int fetch_masking_key(char *msg, int &pos);
    int fetch_payload_length(char *msg, int &pos);
    int fetch_payload(char *msg, int &pos);
private:
    DL_AES               _M_h5aes;
    uint8_t fin_;
    uint8_t opcode_;
    uint8_t mask_;
    uint8_t masking_key_[4];
    uint64_t payload_length_;
    char payload_[2048];
    int fd_;
};

#endif
